package com.itheima.app.controller;

import cn.hutool.core.util.NumberUtil;
import com.itheima.app.manager.SoulManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


@RestController
public class SoulController {

    @Autowired
    SoulManager soulManager;

    @GetMapping("/testSoul")
    public ResponseEntity testSoul(){
        return soulManager.findSoul();
    }

    @PostMapping("/testSoul")
    public ResponseEntity submitSoul(@RequestBody Map<String ,Object> answers){
        List<Map<String,String>> list = (List<Map<String, String>>) answers.get("answers");
        return soulManager.submitSoul(list);

    }

    @GetMapping("/testSoul/report/{id}")
    public ResponseEntity findResult(@PathVariable String id){
        return soulManager.findResult(id);
    }
}
